from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps


class ControlRecipe(ConanFile):
    name = "controls"
    version = "0.0.1"
    license = "No License"
    author = "zhangzhiming@mozihealthcare.cn"
    url = ""
    description = ""
    topics = ""
    settings = ['arch', 'build_type', 'compiler', 'os']
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": True, "fPIC": True}
    # 导出源文件
    exports_sources = {"CMakeLists.txt", "src/*", "include/*"}
    requires = ["common/0.0.1"]

    def layout(self):
        cmake_layout(self)

    def generate(self):
        tc = CMakeToolchain(self)
        tc.variables["CMAKE_CXX_STANDARD"] = "17"
        tc.generate()

        deps = CMakeDeps(self)
        deps.generate()


    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def package(self):
        cmake = CMake(self)
        cmake.install()

    def package_info(self):
        self.cpp_info.set_property("cmake_target_name", "controls")
        self.cpp_info.libs = ["controls"]
